package dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import model.User;
import util.DBUtil;

public class UserDAO {
	public User getUser(String username,String password){
		DBUtil util = new DBUtil("select * from `user` where `USER _NAME` = ? and `USER _PASS` = ?");
		try {
			util.pst.setString(1, username);
			util.pst.setString(2, password);
			ResultSet result = util.pst.executeQuery();
			
			if(result.next()){
				User user =  new User(result.getString(1),result.getString(2),result.getString(3),result.getString(4));
				util.close();
				return user;
			}else{
				util.close();
				return null;
			}
		} catch (SQLException e) {
			e.printStackTrace();
			util.close();
			return null;
		}
	}
}
